package com.woniuxy.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.shop.entity.Product;
import com.woniuxy.shop.mapper.ProductMapper;
import com.woniuxy.shop.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fanqiwen
 * @since 2023-02-07 11:56:02
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
    @Autowired
    ProductMapper productMapper;
    @Override
    public  Page<Product>  pageData(Integer currentPage, Integer pageSIze,String keywords) {
        Page<Product> page=new Page<>(currentPage,pageSIze);
        QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
        if (!StringUtils.isEmpty(keywords)){
            queryWrapper.like("productname",keywords);
        }
        return productMapper.selectPage(page,queryWrapper);

    }
}
